#include "camera.h"

/****************************************************//**
 * Project-Namespace
 ********************************************************/
namespace jae
{

/****************************************************//**
 * Constructor of the class.
 ********************************************************/
Camera::Camera() :
    Object()
{  
    _visibility = false;
    this->yaw(180.0f);
}

/****************************************************//**
 * Destructor of the class.
 ********************************************************/
Camera::~Camera()
{  
    //Nothing to do
}

/****************************************************//**
 * renders the Camera
 ********************************************************/
void Camera::render()
{
    //Draws a simple camera
    if (_visibility)
    {   
        this->renderBegin();

        //Set Materials
        GLfloat ambient[4] = {0.5f, 0.5f, 0.5f, 1.0f};
        GLfloat diffuse[4] = {0.1f, 0.5f, 1.0f, 1.0f};
        GLfloat specular[4] = {0.1f, 0.1f, 0.1f, 1.0f};
        GLfloat emissive[4] = {0.0f, 0.0f, 0.0f, 1.0f};
        GLfloat shininess = 100.0f;

        glMaterialfv( GL_FRONT, GL_AMBIENT, ambient );
        glMaterialfv( GL_FRONT, GL_DIFFUSE, diffuse );
        glMaterialfv( GL_FRONT, GL_SPECULAR, specular );
        glMaterialfv( GL_FRONT, GL_EMISSION, emissive );
        glMaterialf( GL_FRONT, GL_SHININESS, shininess );
        
        glBegin(GL_TRIANGLES);
        
        //Front
        glNormal3f(0.0f, -0.8f, -0.6f);
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-0.15f, 0.15f, -0.2f);
        glVertex3f(0.15f, 0.15f, -0.2f);
        
        glNormal3f(0.8f, 0.0f, -0.6f);
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-0.15f, -0.15f, -0.2f);
        glVertex3f(-0.15f, 0.15f, -0.2f);
        
        glNormal3f(0.0f, 0.8f, -0.6f);
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(0.15f, -0.15f, -0.2f);
        glVertex3f(-0.15f, -0.15f, -0.2f);
        
        glNormal3f(-0.8f, 0.0f, -0.6f);
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(0.15f, 0.15f, -0.2f);
        glVertex3f(0.15f, -0.15f, -0.2f);
        
        //Back
        glNormal3f(0.0f, 0.8f, 0.6f);
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(0.15f, 0.15f, -0.2f);
        glVertex3f(-0.15f, 0.15f, -0.2f);
        
        glNormal3f(-0.8f, 0.0f, 0.6f);
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-0.15f, 0.15f, -0.2f);
        glVertex3f(-0.15f, -0.15f, -0.2f);
        
        glNormal3f(0.0f, -0.8f, 0.6f);
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-0.15f, -0.15f, -0.2f);
        glVertex3f(0.15f, -0.15f, -0.2f);
        
        glNormal3f(0.8f, 0.0f, 0.6f);
        glVertex3f(0.0f, 0.0f, 0.0f);
        glVertex3f(0.15f, -0.15f, -0.2f);
        glVertex3f(0.15f, 0.15f, -0.2f);
        
        glEnd();
        
        glBegin(GL_QUADS);
        
        glNormal3f( 0.0f, -1.0f, 0.0f);
        glVertex3f( 0.2f, -0.2f, 0.0f); // Top Right Of The Quad (Bottom)
        glVertex3f( 0.2f, -0.2f, 0.6f); // Bottom Right Of The Quad (Bottom)
        glVertex3f(-0.2f, -0.2f, 0.6f); // Bottom Left Of The Quad (Bottom)
        glVertex3f(-0.2f, -0.2f, 0.0f); // Top Left Of The Quad (Bottom)
        
        glColor3f(0.5f, 0.5f, 0.5f);
        glNormal3f( 0.0f, 1.0f, 0.0f);
        glVertex3f( 0.2f, 0.2f, 0.6f); // Top Right Of The Quad (Top)
        glVertex3f( 0.2f, 0.2f, 0.0f); // Bottom Right Of The Quad (Top)
        glVertex3f(-0.2f, 0.2f, 0.0f); // Bottom Left Of The Quad (Top)
        glVertex3f(-0.2f, 0.2f, 0.6f); // Top Left Of The Quad (Top)
        
        glNormal3f( 0.0f, 0.0f,-1.0f);
        glVertex3f( 0.2f, 0.2f, 0.0f); // Top Right Of The Quad (Front)
        glVertex3f( 0.2f, -0.2f, 0.0f); // Bottom Right Of The Quad (Front)
        glVertex3f(-0.2f, -0.2f, 0.0f); // Bottom Left Of The Quad (Front)
        glVertex3f(-0.2f, 0.2f, 0.0f); // Top Left Of The Quad (Front)
        
        glNormal3f( 0.0f, 0.0f, 1.0f);
        glVertex3f( 0.2f, -0.2f, 0.6f); // Bottom Left Of The Quad (Back)
        glVertex3f( 0.2f, 0.2f, 0.6f); // Top Left Of The Quad (Back)
        glVertex3f(-0.2f, 0.2f, 0.6f); // Top Right Of The Quad (Back)
        glVertex3f(-0.2f, -0.2f, 0.6f); // Bottom Right Of The Quad (Back)
       
        glNormal3f(-1.0f, 0.0f, 0.0f);
        glVertex3f(-0.2f, 0.2f, 0.0f); // Top Right Of The Quad (Left)
        glVertex3f(-0.2f, -0.2f, 0.0f); // Bottom Right Of The Quad (Left)
        glVertex3f(-0.2f, -0.2f, 0.6f); // Bottom Left Of The Quad (Left)
        glVertex3f(-0.2f, 0.2f, 0.6f); // Top Left Of The Quad (Left)
       
        glNormal3f( 1.0f, 0.0f, 0.0f);
        glVertex3f( 0.2f, 0.2f, 0.6f); // Top Right Of The Quad (Right)
        glVertex3f( 0.2f, -0.2f, 0.6f); // Bottom Right Of The Quad (Right)
        glVertex3f( 0.2f, -0.2f, 0.0f); // Bottom Left Of The Quad (Right)
        glVertex3f( 0.2f, 0.2f, 0.0f); // Top Left Of The Quad (Right)
        glEnd(); // Done Drawing The Quad

        this->renderEnd();
    }
    
}

} //namespace
